﻿using RegexBuilder.Enums;
using System;
using System.Collections.Generic;

namespace RegexBuilder.Interfaces
{
    /// <summary>
    /// 正则建造接口
    /// </summary>
    public interface IRegexBuilderStarter : IRegexStringProvider
    {
        /// <summary>
        /// 通过字符集标记创建要匹配的字符项，并可以添加或排除其他字符，自动去重
        /// </summary>
        /// <param name="charSet">字符标记</param>
        /// <param name="includechars">包含字符</param>
        /// <param name="excludechars">排除字符</param>
        /// <returns></returns>
        IRegexBuilder AddPattern(CharSetEnum charSet, IEnumerable<char>? includechars = null, IEnumerable<char>? excludechars = null);
        /// <summary>
        /// 创建固定字符串的匹配项，当输入为多个时，将变为多个可选匹配 （string1|string2）
        /// </summary>
        /// <param name="strings">匹配字符串</param>
        /// <returns></returns>
        IRegexBuilder AddPattern(IEnumerable<string> strings);

        /// <summary>
        /// 创建固定字符串的匹配项，当输入为多个时，将变为多个可选匹配 （string1|string2）
        /// </summary>
        /// <param name="strings">匹配字符串</param>
        /// <returns></returns>
        IRegexBuilder AddPattern(params string[] strings);

        /// <summary>
        /// 创建复杂正则合并多个构建器结构 （build1|builder2）
        /// </summary>
        /// <param name="builders">建造器列表</param>
        /// <param name="Count">预创建数量，使用预创建后可直接访问</param>
        /// <returns></returns>
        IRegexBuilder AddOptionPattern(Action<IList<IRegexBuilderStarter>> builders, int Count = 0);

        /// <summary>
        /// 通过包含或排除的字符创建匹配项，自动去重
        /// </summary>
        /// <param name="includechars">包含字符</param>
        /// <param name="excludechars">排除字符</param>
        /// <returns></returns>
        IRegexBuilder AddCharSetPattern(IEnumerable<char>? includechars, IEnumerable<char>? excludechars = null);
        /// <summary>
        /// 将字符串转化为字符集，自动去重 abc-> [abc]
        /// </summary>
        /// <param name="includechars">需要转化为字符集的字符串</param>
        /// <returns></returns>
        IRegexBuilder AddIncludeCharSetPattern(IEnumerable<char> includechars);
        /// <summary>
        /// 将字符串转化为排除字符集，自动去重 abc-> [^abc]
        /// </summary>
        /// <param name="excludechars">需要转化为字符集的字符串</param>
        /// <returns></returns>
        IRegexBuilder AddExcludeCharSetPattern(IEnumerable<char> excludechars);
        /// <summary>
        /// 正则原样输入，将输入的字符串原样插入到结果正则表达式中
        /// </summary>
        /// <param name="regex">正则表达式</param>
        /// <returns></returns>
        IRegexBuilderStarter AddRegexPattern(string regex);
    }
}

